home *** CD-ROM | disk | FTP | other *** search
/ Delphi Informant Complete 1995 - 2000 / Delphi Informant Complete 1995 to 2000.iso / Delphi Informant Magazine Complete Works SOURCE CODE 1998.rar / 1998 / Sep / di9809cd / WinPerf.pas < prev    next >
Pascal/Delphi Source File  |  1997-12-12  |  27KB  |  532 lines

  1. unit WinPerf;
  2.  
  3. interface
  4.  
  5. uses Windows;
  6.  
  7. const
  8.   PERF_DATA_VERSION = 1;
  9.   PERF_DATA_REVISION = 1;
  10.  
  11. //  In order for data to be returned through the Configuration Registry
  12. //  in a system-independent fashion, it must be self-describing.
  13.  
  14. //  In the following, all offsets are in bytes.
  15.  
  16. //
  17. //  Data is returned through the Configuration Registry in a
  18. //  a data block which begins with a _PERF_DATA_BLOCK structure.
  19. //
  20.  
  21. type
  22.   PPerf_Data_Block = ^TPerf_Data_Block;
  23.   TPerf_Data_Block = packed record
  24.     Signature    : Array [0..3] of WideChar;   // Signature: Unicode "PERF"
  25.     LittleEndian : DWORD;         // 0 = Big Endian, 1 = Little Endian
  26.     Version      : DWORD;         // Version of these data structures
  27.     Revision     : DWORD;         // Revision of these data structures
  28.     TotalByteLength : DWORD;      // Total length of data block
  29.     HeaderLength    : DWORD;      // Length of this structure
  30.     NumObjectTypes  : DWORD;      // Number of types of objects being reported
  31.     DefaultObject   : LongInt;    // Object Title Index of default
  32.                                   // object to display when data from
  33.                                   // this system is retrieved (-1 =
  34.                                   // none, but this is not expected to
  35.                                   // be used)
  36.     SystemTime  : TSYSTEMTIME;    // Time at the system under measurement
  37.     PerfTime    : TLARGEINTEGER;  // Performance counter value
  38.                                   // at the system under measurement
  39.     PerfFreq    : TLARGEINTEGER;  // Performance counter frequency
  40.                                   // at the system under measurement
  41.     PerfTime100nSec : TLARGEINTEGER;  // Performance counter time in 100 nsec
  42.                                       // units at the system under measurement
  43.     SystemNameLength : DWORD;     // Length of the system name
  44.  
  45.     SystemNameOffset : DWORD;     // Offset, from beginning of this
  46.                                   // structure, to name of system
  47.                                   // being measured
  48.     end;
  49.  
  50. //
  51. //  The _PERF_DATA_BLOCK structure is followed by NumObjectTypes of
  52. //  data sections, one for each type of object measured.  Each object
  53. //  type section begins with a _PERF_OBJECT_TYPE structure.
  54. //
  55.  
  56.   PPerf_Object_Type = ^TPerf_Object_Type;
  57.   TPerf_Object_Type = packed record
  58.     TotalByteLength  : DWORD;     // Length of this object definition
  59.                                     // including this structure, the
  60.                                     // counter definitions, and the
  61.                                     // instance definitions and the
  62.                                     // counter blocks for each instance:
  63.                                     // This is the offset from this
  64.                                     // structure to the next object, if
  65.                                     // any
  66.     DefinitionLength : DWORD;     // Length of object definition,
  67.                                     // which includes this structure
  68.                                     // and the counter definition
  69.                                     // structures for this object: this
  70.                                     // is the offset of the first
  71.                                     // instance or of the counters
  72.                                     // for this object if there is
  73.                                     // no instance
  74.     HeaderLength : DWORD;         // Length of this structure: this
  75.                                     // is the offset to the first
  76.                                     // counter definition for this
  77.                                     // object
  78.     ObjectNameTitleIndex : DWORD; // Index to name in Title Database
  79.     ObjectNameTitle  : PWideChar; // Initially NULL, for use by
  80.                                     // analysis program to point to
  81.                                     // retrieved title string
  82.     ObjectHelpTitleIndex : DWORD; // Index to Help in Title Database
  83.     ObjectHelpTitle : PWideChar;  // Initially NULL, for use by
  84.                                    // analysis program to point to
  85.                                    // retrieved title string
  86.     DetailLevel  : DWORD;      // Object level of detail (for
  87.                                 // controlling display complexity);
  88.                                 // will be min of detail levels
  89.                                 // for all this object's counters
  90.     NumCounters  : DWORD;      // Number of counters in each
  91.                                 // counter block (one counter
  92.                                 // block per instance)
  93.     DefaultCounter : LongInt;  // Default counter to display when
  94.                                 // this object is selected, index
  95.                                 // starting at 0 (-1 = none, but
  96.                                 // this is not expected to be used)
  97.     NumInstances   : LongInt;  // Number of object instances
  98.                                 // for which counters are being
  99.                                 // returned from the system under
  100.                                  // measurement. If the object defined
  101.                                  // will never have any instance data
  102.                                  // structures (PERF_INSTANCE_DEFINITION)
  103.                                  // then this value should be -1, if the
  104.                                  // object can have 0 or more instances,
  105.                                  // but has none present, then this
  106.                                  // should be 0, otherwise this field
  107.                                  // contains the number of instances of
  108.                                  // this counter.
  109.     CodePage : DWORD;           // 0 if instance strings are in
  110.                                  // UNICODE, else the Code Page of
  111.                                  // the instance names
  112.     PerfTime : TLARGEINTEGER;   // Sample Time in "Object" units
  113.     PerfFreq : TLARGEINTEGER;   // Frequency of "Object" units in
  114.                                  // counts per second.
  115.   end;
  116.  
  117. const
  118.   PERF_NO_INSTANCES = -1;  // no instances (see NumInstances above)
  119.  
  120. //
  121. // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  122. //
  123. //  PERF_COUNTER_DEFINITION.CounterType field values
  124. //
  125. //
  126. //        Counter ID Field Definition:
  127. //
  128. //   3      2        2    2    2        1        1    1
  129. //   1      8        4    2    0        6        2    0    8                0
  130. //  +--------+--------+----+----+--------+--------+----+----+----------------+
  131. //  |Display |Calculation  |Time|Counter |        |Ctr |Size|                |
  132. //  |Flags   |Modifiers    |Base|SubType |Reserved|Type|Fld |   Reserved     |
  133. //  +--------+--------+----+----+--------+--------+----+----+----------------+
  134. //
  135. //
  136. //  The counter type is the "or" of the following values as described below
  137. //
  138. //  select one of the following to indicate the counter's data size
  139. //
  140.  
  141.   PERF_SIZE_DWORD = $00000000;
  142.   PERF_SIZE_LARGE = $00000100;
  143.   PERF_SIZE_ZERO  = $00000200;  // for Zero Length fields
  144.   PERF_SIZE_VARIABLE_LEN = $00000300;  // length is in CounterLength field
  145.                                         // of Counter Definition struct
  146. //
  147. //  select one of the following values to indicate the counter field usage
  148. //
  149.   PERF_TYPE_NUMBER   = $00000000;  // a number (not a counter)
  150.   PERF_TYPE_COUNTER  = $00000400;  // an increasing numeric value
  151.   PERF_TYPE_TEXT     = $00000800;  // a text field
  152.   PERF_TYPE_ZERO     = $00000C00;  // displays a zero
  153.  
  154. //
  155. //  If the PERF_TYPE_NUMBER field was selected, then select one of the
  156. //  following to describe the Number
  157. //
  158.   PERF_NUMBER_HEX      = $00000000;  // display as HEX value
  159.   PERF_NUMBER_DECIMAL  = $00010000;  // display as a decimal integer
  160.   PERF_NUMBER_DEC_1000 = $00020000;  // display as a decimal/1000
  161.  
  162. //
  163. //  If the PERF_TYPE_COUNTER value was selected then select one of the
  164. //  following to indicate the type of counter
  165. //
  166.   PERF_COUNTER_VALUE     = $00000000;  // display counter value
  167.